(ns client.search
    "This namespace contains the functions to search a field from all the tuples in a map given the word."
  (:gen-class)
    (:require clojure.contrib.gen-html-docs))

(defn generate-pattern
      "Function that creates a regex string based on the first character"
      [pattern]
      (if (= \$ (first pattern))
      (str "\\" pattern "[0-9]*.?[0-9]*")
      (str pattern " {0}[a-zA-Z]*")))

(defn search
      "Function that returns the tuples that match pattern"      
      [table pattern where]
(for [r table :when (not (nil? (re-find (re-pattern (generate-pattern pattern)) (where r))))] r))



